package com.haima.test1;

import java.util.ArrayList;

public class Student {
    private String name;
    private int age;
    private double grade;
    private ArrayList<Student> list;

    public Student() {
    }

    public Student(String name, int age, double grade) {
        this.name = name;
        this.age = age;
        this.grade = grade;
    }

    public Student(String name, int age, double grade, ArrayList<Student> list) {
        this.name = name;
        this.age = age;
        this.grade = grade;
        this.list = list;
    }

    public String getName() {
        return name;
    }

    public void setName(String name) {
        this.name = name;
    }

    public int getAge() {
        return age;
    }

    public void setAge(int age) {
        this.age = age;
    }

    public double getGrade() {
        return grade;
    }

    public void setGrade(double grade) {
        this.grade = grade;
    }

    public ArrayList<Student> getList() {
        return list;
    }

    public void setList(ArrayList<Student> list) {
        this.list = list;
    }

    public void getAverage() {
        double average = 0;
        double sum = 0;
        for (int i = 0; i < list.size(); i++) {
            Student stu = list.get(i);
            sum += stu.getGrade();
        }
        average = sum / list.size();
        System.out.println("学生平均分数为:" + average);
    }
}
